<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>拷贝哈希运算上下文</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.hash-copy" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">hash_copy</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7)</p><p class="refpurpose"><span class="refname">hash_copy</span> &mdash; <span class="dc-title">拷贝哈希运算上下文</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.hash-copy-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>hash_copy</strong></span>
    ( <span class="methodparam"><span class="type"><span class="type HashContext">HashContext</span></span> <code class="parameter">$context</code></span>
   ) : <span class="type"><span class="type HashContext">HashContext</span></span></div>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.hash-copy-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">context</code></dt>

     <dd>

      <p class="para">
       由 <span class="function"><a href="hash_init.html" class="function">hash_init()</a></span> 函数返回的哈希运算上下文。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.hash-copy-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回哈希运算上下文的一个复本。
  </p>
 </div>

 
 <div class="refsect1 changelog" id="refsect1-function.hash-copy-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>7.2.0</td>
       <td>
        接受的参数以及返回值从资源类型修改为 <strong class="classname">HashContext</strong> 对象类型。
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.hash-copy-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-889">
    <p><strong>Example #1 <span class="function"><strong>hash_copy()</strong></span> 例程</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$context&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">hash_init</span><span style="color: #007700">(</span><span style="color: #DD0000">"md5"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">hash_update</span><span style="color: #007700">(</span><span style="color: #0000BB">$context</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"data"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;拷贝上下文资源以便继续使用&nbsp;*/<br /></span><span style="color: #0000BB">$copy_context&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">hash_copy</span><span style="color: #007700">(</span><span style="color: #0000BB">$context</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">hash_final</span><span style="color: #007700">(</span><span style="color: #0000BB">$context</span><span style="color: #007700">),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">hash_update</span><span style="color: #007700">(</span><span style="color: #0000BB">$copy_context</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"data"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">hash_final</span><span style="color: #007700">(</span><span style="color: #0000BB">$copy_context</span><span style="color: #007700">),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
8d777f385d3dfec8815d20f7496026dc
511ae0b1c13f95e5f08f1a0dd3da3d93
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div></div></div></body></html>